<?php

$con = mysqli_connect("localhost","root","root");
if (!$con)
{
    die('连接失败: ' . mysqli_error($con));
}else{
    echo "连接成功<br>";
}

if (mysqli_select_db($con,"PHPProjects")){
    echo "连接数据库成功<br>";
}else{
    echo "连接数据库失败<br>";
}

//mysqli_query($con,"INSERT INTO comment (id,uname, comment)
//VALUES ('1', '张三', '哈哈哈')");
//mysqli_query($con,"INSERT INTO comment (id, uname, comment)
//VALUES ('2', '李四', '嘻嘻嘻')");

//$sql="INSERT INTO comment (uname, comment)
//VALUES
//('$_POST[uname]','$_POST[comment]')";
//if (!mysqli_query($con,$sql))
//{
//    die('添加错误: ' . mysqli_error($con));
//}else{
//    echo "添加成功";添加成功
//}


//$result = mysqli_query($con,"SELECT * FROM comment");
//echo "<table border='1'>
//<tr>
//<th>名字</th>
//<th>评论</th>
//</tr>";
//while($row = mysqli_fetch_array($result))
//{
//    echo "<tr>";
//    echo "<td>" . $row['uname'] . "</td>";
//    echo "<td>" . $row['comment'] . "</td>";
//    echo "</tr>";
//}
//echo "</table>";

//mysqli_query($con,"UPDATE comment SET uname = '赵六',comment = 'xxhh'
//WHERE id = '2'");

//mysqli_query($con,"DELETE FROM comment WHERE uname='赵六'");

mysqli_close($con);






?>